package com.example.app.model;

import android.os.Parcel;
import android.os.Parcelable;

public class ChatMessage implements Parcelable {
    public static final int TYPE_USER = 1;  // 用户消息
    public static final int TYPE_AI = 2;    // AI回复消息

    private String content;
    private int type;
    private long timestamp;

    public ChatMessage(String content, int type) {
        this.content = content;
        this.type = type;
        this.timestamp = System.currentTimeMillis();
    }

    protected ChatMessage(Parcel in) {
        content = in.readString();
        type = in.readInt();
        timestamp = in.readLong();
    }

    public static final Creator<ChatMessage> CREATOR = new Creator<ChatMessage>() {
        @Override
        public ChatMessage createFromParcel(Parcel in) {
            return new ChatMessage(in);
        }

        @Override
        public ChatMessage[] newArray(int size) {
            return new ChatMessage[size];
        }
    };

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getType() {
        return type;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTime(long time) {
        this.timestamp = time;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(content);
        dest.writeInt(type);
        dest.writeLong(timestamp);
    }
} 